In [46]:
from IPython.display import HTML
HTML('''<script>
code_show=true; 
function code_toggle() {
 if (code_show){
 $('div.input').hide();
 } else {
 $('div.input').show();
 }
 code_show = !code_show
} 
$( document ).ready(code_toggle);
</script>
The raw code for this IPython notebook is by default hidden for easier reading.
To toggle on/off the raw code, click <a href="javascript:code_toggle()">here</a>.''')
Out[46]:
The raw code for this IPython notebook is by default hidden for easier reading. To toggle on/off the raw code, click here.
In [47]:
#hide warnings
HTML('''<script>
code_show_err=true; 
function code_toggle_err() {
 if (code_show_err){
 $('div.output_stderr').hide();
 } else {
 $('div.output_stderr').show();
 }
 code_show_err = !code_show_err
} 
$( document ).ready(code_toggle_err);
</script>
To toggle on/off output errors, click <a href="javascript:code_toggle_err()">here</a>.''')
Out[47]:
To toggle on/off output errors, click here.
In [48]:
print('Testing GAL4 lines upstream to 64A11-LexA')
print('Project A83, Daniel Bushey')
Testing GAL4 lines upstream to 64A11-LexA
Project A83, Daniel Bushey
In [49]:
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))
In [50]:
import pandas as pd
import os
import sys
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
import ccModules as cc
import ccModules2 as cc2

from IPython.html.widgets import interact
import pandas as pd
from IPython.display import IFrame
from bokeh.palettes import Spectral4
from bokeh.plotting import figure, output_file, show
In [51]:
#load project  specific parameters
from A83_init20190220 import *
In [59]:
#load data
#load pandas data frame
exceldata = pd.read_hdf(os.path.join(saveFig, 'Compiled_data.hdf5'), 'data')
#print(exceldata.shape)
#exceldata = exceldata[exceldata['Grade'] == 1]
In [60]:
exceldata
Out[60]:
Baseline Shift Beam strength Date Directory? Dissection End Dissection Quality Dissection Start Gender Genotype Grade ... VNC View Intensity_Data_File Path TimeSeries_Image_Files Two_Colored_Image voltage timestamp intensity_data Cross
0 NaN 15 20190214 True 1330 NaN 1320 F SS33917 NaN ... 0 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flya_20190214-A83-20_stim30s06V_00001_00066.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.988], [3.992], [4.996],... {'Name': {'Background': 'Background', 'Region1... A83-20
1 NaN 15 20190214 True 1330 NaN 1320 F SS33917 NaN ... 0 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flya_20190214-A83-20_stimDur300at15_00001_00... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.988], [3.992], [4.996],... {'Name': {'Background': 'Background', 'Region1... A83-20
2 NaN 15 20190214 True 1345 NaN 1338 F SS00550 NaN ... 0 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flya_20190214-A83-73_stim30s06V_00001_00078.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-73
3 NaN 15 20190214 True 1345 NaN 1338 F SS00550 NaN ... 0 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flya_20190214-A83-73_stimDur300at15_00001_00... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-73
4 NaN 15 20190214 True 1404 left lamina missing 1353 F JRC_SS04956-LH989 NaN ... 0 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flya_20190214-A83-69_stimDur300at15_00001_00... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-69
5 NaN 15 20190214 True 1404 left lamina missing 1353 F JRC_SS04956-LH989 NaN ... 0 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flya_20190214-A83-69_stim30s06V_00001_00078.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-69
6 NaN 15 20190214 True 1413 NaN 1407 F JRC_SS04956-LH989 NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flyd_20190214-A83-69_stim30s06V_00001_00066.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-69
7 NaN 15 20190214 True 1413 NaN 1407 F JRC_SS04956-LH989 NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flyd_20190214-A83-69_stimDur300at15_00001_00... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-69
8 NaN 15 20190214 True 1428 NaN 1422 F JRC_SS03795-LH728 NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flye_20190214-A83-70_stim30s06V_00001_00078.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-70
9 NaN 15 20190214 True 1428 NaN 1422 F JRC_SS03795-LH728 NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flye_20190214-A83-70_stimDur300at15_00001_00... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-70
10 NaN 15 20190214 True NaN NaN NaN F JRC_SS03795-LH728 NaN ... 0 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flyf_20190214-A83-70_stim30s06V_00001_00078.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-70
11 NaN 15 20190214 True NaN NaN NaN F JRC_SS03795-LH728 NaN ... 0 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flyf_20190214-A83-70_stimDur300at15_00001_00... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-70
12 NaN 15 20190214 True 1459 NaN 1453 F JRC_SS22614-LH1396 NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flyg_20190214-A83-72_stim30s06V_00001_00078.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-72
13 NaN 15 20190214 True 1459 NaN 1453 F JRC_SS22614-LH1396 NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flyg_20190214-A83-72_stimDur300at15_00001_00... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-72
14 NaN 15 20190214 True 1514 NaN 1509 F JRC_SS33917 NaN ... 0 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flyh_20190214-A83-40_stim30s06V_00001_00078.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-40
15 NaN 15 20190214 True 1514 NaN 1509 F JRC_SS33917 NaN ... 0 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flyh_20190214-A83-40_stimDur300at15_00001_00... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-40
16 NaN 15 20190213 True 1432 NaN 1422 F SS33917 NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flya_20190213-A83-20_stim30s06V_00001_00078.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-20
17 NaN 15 20190213 True 1432 NaN 1422 F SS33917 NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flya_20190213-A83-20_stimDur300at15_00001_00... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-20
18 NaN 15 20190213 True 1545 NaN 1537 F JRC_SS04956-LH989 NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flye_20190213-A83-69_stim30s06V_00001_00078.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-69
19 NaN 15 20190213 True 1545 NaN 1537 F JRC_SS04956-LH989 NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flye_20190213-A83-69_stimDur300at15_00001_00... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-69
20 NaN 15 20190213 True 1731 partial vnce attached 1724 F JRC_SS03795-LH728 NaN ... 0 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flyf_20190213-A83-70_stimDur300at15_00001_00... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-70
21 NaN 15 20190213 True 1731 partial vnce attached 1724 F JRC_SS03795-LH728 NaN ... 0 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flyf_20190213-A83-70_stim30s06V_00001_00078.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-70
22 NaN 15 20190213 True 1745 NaN 1739 F JRC_SS22614-LH1396 NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flyg_20190213-A83-72_stim30s06V_00001_00078.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-72
23 NaN 15 20190213 True 1745 NaN 1739 F JRC_SS22614-LH1396 NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flyg_20190213-A83-72_stimDur300at15_00001_00... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-72
24 NaN 15 20190213 True 1801 NaN 1756 F SS00550 NaN ... 0 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flyh_20190213-A83-73_stim30s06V_00001_00078.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-73
25 NaN 15 20190213 True 1801 NaN 1756 F SS00550 NaN ... 0 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flyh_20190213-A83-73_stimDur300at15_00001_00... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-73
26 NaN 15 20190211 True 1401 partial vnc attached 1355 F SS33917 NaN ... 0 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flya_20190211-A83-20_stim30s06V_00001_00078.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-20
27 NaN 15 20190211 True 1401 partial vnc attached 1355 F SS33917 NaN ... 0 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flya_20190211-A83-20_stimDur300at15_00001_00... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-20
36 NaN 15 20190211 True 1528 NaN 1520 F JRC_SS33917 NaN ... 0 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flyf_20190211-A83-40_stim30s06V_00001_00078.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.982], [1.985], [2.99], [3.994], [4.996], [... {'Name': {'Background': 'Background', 'Region1... A83-40
37 NaN 15 20190211 True 1528 NaN 1520 F JRC_SS33917 NaN ... 0 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flyf_20190211-A83-40_stimDur300at15_00001_00... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.982], [1.985], [2.99], [3.994], [4.996], [... {'Name': {'Background': 'Background', 'Region1... A83-40
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
208 NaN 10 20190114 True 1445 lamina both partial vnc attached 1439 F SS33917 NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flyb_20190114-A83-20_stim30s06V_00001_00078.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-20
209 NaN 10 20190114 True 1511 no lamina vnce attached 1505 F MB310C NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flyd_20190114-A83-21_stim30s06V_00001_00078.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-21
210 NaN 10 20190114 True 1527 right lamina partial Vnc 1521 F MB310C NaN ... 0 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flye_20190114-A83-21_stim30s06V_00001_00078.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.982], [1.985], [2.99], [3.994], [4.996], [... {'Name': {'Background': 'Background', 'Region1... A83-21
211 NaN 10 20190114 True 1544 right lamina partial vnce 1538 F SS45234 NaN ... 0 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flyf_20190114-A83-23_stim30s06V_00001_00078.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.982], [1.985], [2.99], [3.994], [4.996], [... {'Name': {'Background': 'Background', 'Region1... A83-23
212 NaN 10 20190114 True 1558 lamina both vnce attached 1551 F SS45234 NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flyg_20190114-A83-23_stim30s06V_00001_00066.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.982], [1.985], [2.99], [3.994], [4.996], [... {'Name': {'Background': 'Background', 'Region1... A83-23
213 NaN 10 20190111 True 1519 NaN 1512 F SS33917 NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flya_20190111-A83-20_stim30s06V_00001_00078.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-20
214 NaN 10 20190111 True 1534 left lamina vnc attached 1528 F MB082C NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flyb_20190111-A83-22_stim30s06V_00001_00284.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-22
215 NaN 10 20190111 True 1550 perfect 1543 F SS33917 NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flyc_20190111-A83-20_stim30s06V_00001_00078.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.982], [1.985], [2.99], [3.994], [4.996], [... {'Name': {'Background': 'Background', 'Region1... A83-20
216 NaN 10 20190111 True 1617 partial vnc attached partial lamina left 1611 F SS33917 NaN ... 0 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flyd_20190111-A83-20_stim30s06V_00001_00066.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.982], [1.985], [2.99], [3.994], [4.996], [... {'Name': {'Background': 'Background', 'Region1... A83-20
217 NaN 10 20190110 True 1702 some retina on right side 1651 F SS33917 NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flya_20190110-A83-20_stim30s06V_00001_00078.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-20
218 NaN 10 20190110 True 1721 NaN 1709 F MB082C NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flyb_20190110-A83-22_stim30s06V_00001_00078.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-22
219 NaN 10 20190110 True 1736 NaN 1727 F MB082C NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['flyc_20190110-A83-22_stim30s06V_00001_00078.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-22
220 NaN 10 20190109 True 833 no vnc lamina attached 826 F SS33917 NaN ... 0 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['20190109-A83-20-flya_stim30s06V_00001_00132.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-20
221 NaN 10 20190109 True 853 vnc attached no lamina 845 F MB082C NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['20190109-A83-22-flyb_stim30s06V_00001_00131.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.982], [1.985], [2.99], [3.994], [4.996], [... {'Name': {'Background': 'Background', 'Region1... A83-22
222 NaN 10 20190109 True 916 vnc attached no lamina 910 F MB082C NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['20190109-A83-22-flyc_stim30s06V_00001_00131.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.982], [1.985], [2.99], [3.994], [4.996], [... {'Name': {'Background': 'Background', 'Region1... A83-22
223 NaN 10 20190109 True 932 retina right vnc attached 926 F MB082C NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['20190109-A83-22-flyd_stim30s06V_00001_00131.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.982], [1.985], [2.99], [3.994], [4.996], [... {'Name': {'Background': 'Background', 'Region1... A83-22
224 NaN 10 20190108 True 1315 left lamina vnc attached 1306 F MB434B NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['20190108-A83-26-flya_stim30s06V_00001_00154.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-26
225 NaN 10 20190108 True 1328 right lamina attached vnc attached 1320 F MB434B NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['20190108-A83-26-flyb50Per_stim30s06V_00001_0... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-26
226 NaN 25 20190108 True 1416 no lamina vnc attached 1405 F MB434B NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['20190108-A83-26-flyc_stim30s06V_00001_00182.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-26
227 NaN 20 20190108 True 1450 lamina but no vnc 1445 F MB434B NaN ... 0 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['20190108-A83-26-flyd_stim30s06V_00001_00154.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.9814], [1.985], [2.99], [3.994], [4.996], ... {'Name': {'Background': 'Background', 'Region1... A83-26
228 NaN 10 20190108 True 1549 left lobe streched with some retina vnc attached 1541 F SS33917 NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['20190108-A83-20-flyf_stim30s06V_00001_00132.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.982], [1.985], [2.99], [3.994], [4.996], [... {'Name': {'Background': 'Background', 'Region1... A83-20
229 NaN 10 20190108 True 1612 NaN 1600 F SS33917 NaN ... 0 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['20190108-A83-20-flyg_stim30s06V_00001_00132.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.982], [1.985], [2.99], [3.994], [4.996], [... {'Name': {'Background': 'Background', 'Region1... A83-20
230 NaN 10 20190108 True 1627 right lamina left no lamina vnc attached 1621 F SS33917 NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['20190108-A83-20-flyh_stim30s06V_00001_00132.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.982], [1.985], [2.99], [3.994], [4.996], [... {'Name': {'Background': 'Background', 'Region1... A83-20
231 NaN 10 20190108 True 1650 NaN 1644 F SS33917 NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['20190108-A83-20-flyi_stim30s06V_00001_00130.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.982], [1.985], [2.99], [3.994], [4.996], [... {'Name': {'Background': 'Background', 'Region1... A83-20
232 NaN 10 20190108 True 1708 NaN 1701 F MB082C NaN ... 0 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['20190108-A83-22-flyj_stim30s06V_00001_00131.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.982], [1.985], [2.99], [3.994], [4.996], [... {'Name': {'Background': 'Background', 'Region1... A83-22
233 NaN 10 20190107 True 1602 lamina attached trachea removed posterior 1555 F SS33917 NaN ... 0 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['20190107-A83-20-flyc_stim30s06V_00001_00131.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.982], [1.985], [2.99], [3.994], [4.996], [... {'Name': {'Background': 'Background', 'Region1... A83-20
234 NaN 10 20190107 True 1617 lamina right lamina attached 1609 F SS33917 NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['20190107-A83-20-flyd_stim30s06V_00001_00132.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.982], [1.985], [2.99], [3.994], [4.996], [... {'Name': {'Background': 'Background', 'Region1... A83-20
235 NaN 10 20190107 True 1700 right lamina no vnc 1655 F MB082C NaN ... 0 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['20190107-A83-22-flye_stim30s06V_00001_00131.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.982], [1.985], [2.99], [3.994], [4.996], [... {'Name': {'Background': 'Background', 'Region1... A83-22
236 NaN 10 20190107 True 1715 lamina vnc attached 1707 F MB310C NaN ... 1 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['20190107-A83-21-flyf_stim30s06V_00001_00131.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.982], [1.985], [2.99], [3.994], [4.996], [... {'Name': {'Background': 'Background', 'Region1... A83-21
237 NaN 10 20190107 True 1733 lamina no vnc 1724 F MB310C NaN ... 0 Posterior /media/daniel/Seagate Backup Plus Drive/A83/A8... /media/daniel/Seagate Backup Plus Drive/A83/A8... ['20190107-A83-21-flyg_stim30s06V_00001_00131.... /media/daniel/Seagate Backup Plus Drive/A83/A8... [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.... [[0.982], [1.985], [2.99], [3.994], [4.996], [... {'Name': {'Background': 'Background', 'Region1... A83-21

218 rows × 40 columns

In [53]:
print('Checking how many sessions included in the loaded data set:')
print(len(exceldata))
Checking how many sessions included in the loaded data set:
218
In [54]:
print('Stim Protocols')
exceldata['Stim Protocol'].unique()
Stim Protocols
Out[54]:
array(['stim30s06V', 'stimDur300at15'], dtype=object)
In [55]:
#combine stim protocols into one data frame
shortlist1 = exceldata[exceldata['Stim Protocol'] == 'stim30s06V']
shortlist2 = exceldata[exceldata['Stim Protocol'] == 'stimDur300at15']
for row, dseries in shortlist1.iterrows():
    target = shortlist2[shortlist2['Sample Name'] == dseries['Sample Name']] 
    if len(target) >0:
        shortlist1['timestamp'].loc[row] = np.concatenate((dseries['timestamp'],  target['timestamp'].values[0] + dseries['timestamp'][-1]), axis=0)
        shortlist1['voltage'].loc[row] = np.concatenate((dseries['voltage'],  target['voltage'].values[0]), axis=0)
        #no add the signals together
        combined_intensity = {}
        for ckey in dseries['intensity_data']['intensity']:
            target_intensity = target['intensity_data'].iloc[0]
            combined_intensity[ckey] = np.concatenate((dseries['intensity_data']['intensity'][ckey], target_intensity['intensity'][ckey]))
        shortlist1['intensity_data'].loc[row]['intensity'] = combined_intensity
    else: # select only those samples that have both stimulation periods
        shortlist1.drop([row], inplace=True)
exceldata=shortlist1
/home/daniel/anaconda3/lib/python3.6/site-packages/ipykernel_launcher.py:7: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  import sys
/home/daniel/anaconda3/lib/python3.6/site-packages/ipykernel_launcher.py:8: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  
In [56]:
#pull out roi data and add each roi as separate row
exceldata = cc2.pullIntensityData(exceldata)
In [57]:
#check parameters within data
parameters_to_compare = ['Cross']
print('These are the different conditions tested.')
for cp in parameters_to_compare:
    print('Parameter:', cp)
    print(exceldata[cp].unique())
These are the different conditions tested.
Parameter: Cross
['A83-20' 'A83-73' 'A83-69' 'A83-70' 'A83-72' 'A83-40' 'A83-68' 'A83-67'
 'A83-65' 'A83-66' 'A83-64' 'A83-63' 'A83-30' 'A83-26' 'A83-21' 'A83-27'
 'A83-29' 'A83-28' 'A83-62' 'A83-24' 'A83-23' 'A83-61']
In [58]:
#Get counts
print('Number of animals tested.')
groups = exceldata.groupby(['Cross', 'roi'])
groups['roi'].count()
Number of animals tested.
Out[58]:
Cross   roi       
A83-20  Background    9
        Region1       9
        Region2       9
A83-21  Background    2
        Region1       2
        Region2       2
A83-23  Background    4
        Region1       4
        Region2       3
A83-24  Background    6
        Region1       6
        Region2       4
A83-26  Background    4
        Region1       4
        Region2       3
A83-27  Background    5
        Region1       5
        Region2       5
A83-28  Background    6
        Region1       6
        Region2       5
A83-29  Background    5
        Region1       5
        Region2       5
A83-30  Background    4
        Region1       4
        Region2       3
A83-40  Background    3
        Region1       3
A83-61  Background    7
                     ..
A83-63  Background    1
        Region1       1
        Region2       1
A83-64  Background    2
        Region1       2
        Region2       2
A83-65  Background    2
        Region1       2
        Region2       2
A83-66  Background    4
        Region1       4
        Region2       2
A83-67  Background    2
        Region1       2
        Region2       1
A83-68  Background    2
        Region1       2
        Region2       2
A83-69  Background    3
        Region1       3
        Region2       3
A83-70  Background    3
        Region1       3
        Region2       3
A83-72  Background    2
        Region1       2
        Region2       2
A83-73  Background    2
        Region1       2
        Region2       2
Name: roi, Length: 65, dtype: int64
In [14]:
from bokeh.io import output_notebook, show
from bokeh.plotting import figure, output_file, show, ColumnDataSource
from bokeh.models import Range1d
In [15]:
output_notebook()
Loading BokehJS ...
In [16]:
#create a dictionary holding data
raw_data={}
notroi = 'Background' #will look at all rois except background
for cgroup, frame1 in exceldata.groupby('Genotype'):
    crois = frame1['roi'].unique()
    crois = [ccroi for ccroi in crois if ccroi != notroi]
    for croi in crois:
        groupname = cgroup + '_' + croi
        frame2 = frame1[frame1['roi'] == croi]
        if len(frame2) != 0:
            frame3 = cc2.intensityDataFrame(frame2)
            raw_data[groupname] = frame3.subtractBackground(exceldata)
In [17]:
raw_data.keys()
Out[17]:
dict_keys(['G0239_Region1', 'G0239_Region2', 'GR5A-G4_Region1', 'GR5A-G4_Region2', 'JRC_SS03795-LH728_Region1', 'JRC_SS03795-LH728_Region2', 'JRC_SS04956-LH989_Region1', 'JRC_SS04956-LH989_Region2', 'JRC_SS15249-LH185_Region1', 'JRC_SS15249-LH185_Region2', 'JRC_SS22614-LH1396_Region1', 'JRC_SS22614-LH1396_Region2', 'JRC_SS22646-LH153_Region1', 'JRC_SS22646-LH153_Region2', 'JRC_SS22802-LH990_Region1', 'JRC_SS22802-LH990_Region2', 'JRC_SS24679-LH219_Region1', 'JRC_SS24679-LH219_Region2', 'JRC_SS33917_Region1', 'MB077C_Region1', 'MB077C_Region2', 'MB112C_Region1', 'MB112C_Region2', 'MB310C_Region1', 'MB310C_Region2', 'MB310C_G0239_Region1', 'MB310C_G0239_Region2', 'MB433B_Region1', 'MB433B_Region2', 'MB434B_Region1', 'MB434B_Region2', 'SS00550_Region1', 'SS00550_Region2', 'SS01308_Region1', 'SS01308_Region2', 'SS01371-LH2446_Region1', 'SS01371-LH2446_Region2', 'SS32259_Region1', 'SS32259_Region2', 'SS33917_Region1', 'SS33917_Region2', 'SS45234_Region1', 'SS45234_Region2'])
In [39]:
t = raw_data['SS33917_Region1']['intensity'].values
len(t[0])
plt.plot(t[0])
Out[39]:
[<matplotlib.lines.Line2D at 0x7fdbe37eeda0>]
In [18]:
volt = cc2.intensityDataFrame(exceldata).getVoltage()
timevolt = np.arange(0, len(volt))/100
plot=figure(y_range = (timevolt[0], timevolt[-1]), x_range = (0, 0.9), plot_width=600, plot_height=200)
plot=figure( plot_width=600, plot_height=200)
source = ColumnDataSource(data=dict(y=volt, x= timevolt ))
plot.line('x', 'y', source = source, line_width = 3, line_color ='red')
plot.x_range = Range1d(0, np.max(timevolt)*1.05)
plot.y_range = Range1d(0,np.max(volt)*1.05)
plot.xaxis.axis_label = 'Time (S)'
plot.yaxis.axis_label = 'Volt (V)'
#plot.line(timevolt,volt)
#output_file("StimProtocol.html", title = 'Stimulation Protocol')
show(plot)
In [19]:
from bokeh.models import LinearAxis, Range1d
from bokeh.palettes import Spectral5
from bokeh.models import Legend
In [20]:
colors = [(139, 69, 19), (154, 205, 50), (0, 238, 238), (123, 104, 238), (221, 160, 221)]
colors = dict(zip(raw_data.keys(), colors))
print(colors)
{'G0239_Region1': (139, 69, 19), 'G0239_Region2': (154, 205, 50), 'GR5A-G4_Region1': (0, 238, 238), 'GR5A-G4_Region2': (123, 104, 238), 'JRC_SS03795-LH728_Region1': (221, 160, 221)}
In [21]:
exceldata.columns
Out[21]:
Index(['index', 'Baseline Shift', 'Beam strength', 'Date', 'Directory?',
       'Dissection End', 'Dissection Quality', 'Dissection Start', 'Gender',
       'Genotype', 'Grade', 'Imaging Protocol', 'Imaging Start',
       'Lamina Present', 'Magnification', 'No.', 'Notes', 'Notes2', 'Paths',
       'Random', 'Responds', 'Room Temp (°C)', 'Saline', 'Saline Temp (°C)',
       'Sample Movement', 'Sample Name', 'Scope', 'Stage', 'Stage Start',
       'Starvation Media', 'Stim Protocol', 'VNC', 'View',
       'Intensity_Data_File', 'Path', 'TimeSeries_Image_Files',
       'Two_Colored_Image', 'voltage', 'timestamp', 'Cross', 'roi', 'Type',
       'Z:XY', 'image_file', 'image_shape', 'intensity', 'mask_index'],
      dtype='object')
In [22]:
source = ColumnDataSource(exceldata)
In [23]:
source.column_names
Out[23]:
['index',
 'Baseline Shift',
 'Beam strength',
 'Date',
 'Directory?',
 'Dissection End',
 'Dissection Quality',
 'Dissection Start',
 'Gender',
 'Genotype',
 'Grade',
 'Imaging Protocol',
 'Imaging Start',
 'Lamina Present',
 'Magnification',
 'No.',
 'Notes',
 'Notes2',
 'Paths',
 'Random',
 'Responds',
 'Room Temp (°C)',
 'Saline',
 'Saline Temp (°C)',
 'Sample Movement',
 'Sample Name',
 'Scope',
 'Stage',
 'Stage Start',
 'Starvation Media',
 'Stim Protocol',
 'VNC',
 'View',
 'Intensity_Data_File',
 'Path',
 'TimeSeries_Image_Files',
 'Two_Colored_Image',
 'voltage',
 'timestamp',
 'Cross',
 'roi',
 'Type',
 'Z:XY',
 'image_file',
 'image_shape',
 'intensity',
 'mask_index']
In [24]:
p = figure(plot_width=800, plot_height=400, y_range=Range1d(min1, max1), x_range = Range1d(0, np.max(timeStamp)), x_axis_label = 'Time (S)', y_axis_label = 'Intensity - Background')
c = p.line('timestamp', 'intensity', source=source, line_width=2, line_color = (0, 0, 0))
show(p)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-24-3a1fc12b2595> in <module>
----> 1 p = figure(plot_width=800, plot_height=400, y_range=Range1d(min1, max1), x_range = Range1d(0, np.max(timeStamp)), x_axis_label = 'Time (S)', y_axis_label = 'Intensity - Background')
      2 c = p.line('timestamp', 'intensity', source=source, line_width=2, line_color = (0, 0, 0))
      3 show(p)

NameError: name 'min1' is not defined
In [25]:
testframe = pd.DataFrame({'intensity' : [1,2,3,4], 'time' : [2,4,6,8]})
src = ColumnDataSource(testframe)
p = figure(plot_width=800, plot_height=400, y_range=Range1d(0, 10), x_range = Range1d(0, 10), x_axis_label = 'Time (S)', y_axis_label = 'Intensity - Background')
c = p.line('time', 'intensity', source=src, line_width=2, line_color = (0, 0, 0))
show(p)
In [41]:
plt.plot(timeStamp, np.mean(data, axis=0))
Out[41]:
[<matplotlib.lines.Line2D at 0x7fdbdd908320>]
In [45]:
#Intensity Data (subtract background plot)
#Each figure will plot a different gentoype
#black line is mean value
#light grey lines are individual data
timeStamp = cc2.intensityDataFrame(exceldata).getTimeStamp()
for ckey in list(raw_data.keys()):
    #get the min and max range for the data
    data = np.vstack(raw_data[ckey]['intensity'])
    min1 = np.min(data)
    max1 = np.max(data)
    p = figure(plot_width=800, plot_height=400, y_range=Range1d(min1, max1), x_range = Range1d(0, np.max(timeStamp)), x_axis_label = 'Time (S)', y_axis_label = 'Intensity - Background')
    #plot showing voltage
    p.title.text = ckey
    p.extra_y_ranges = {"foo": Range1d(start=-0, end=2)}
    p.add_layout(LinearAxis(y_range_name='foo', axis_label = 'Volt (V)'), 'right')
    c = p.line(timevolt, volt, y_range_name = 'foo', line_color = (255,0, 0), line_alpha=0.5, line_width =2)

    #plot showing mean data results
    legend_it = [('Voltage', [c])]
    c = p.line(x=timeStamp, y=np.mean(data, axis=0), line_width=2, line_color = (0, 0, 0))
    legend_it.append(('Mean', [c]))
    for row in range(0,data.shape[0]):
        c = p.line(x=timeStamp, y=data[row, :], line_width=2, line_color = (150, 150, 150), line_alpha = 0.5) #line_color = colors[cgroup])
        legend_it.append((raw_data[ckey]['Sample Name'].iloc[row], [c]))


    #p.sizing_mode = 'scale_width'

    legend = Legend(items = legend_it, location=(0, 100))
    legend.click_policy="hide"
    p.add_layout(legend, 'right')


    

    #p.x_range = Range1d(0, 450)
    p.y_range = Range1d(min1, max1)
    #output_file("Mean-RawIntensity.html", title = 'Stimulation Protocol')
    #p.patch(timevolt2, volt2, y_range_name = 'foo')
    show(p)
In [225]:
#Intensity Data (subtract background plot)
timeStamp = cc2.intensityDataFrame(exceldata).getTimeStamp()
#get the min and max range for the data
data = []
for ckey in raw_data.keys():
    data.append( np.mean(np.vstack(raw_data[ckey]['intensity'].values), axis=0))
data=np.vstack(data)
data.shape
min1 = np.min(data)
max1 = np.max(data)
p = figure(plot_width=800, plot_height=400, y_range=(min1, max1), x_range = (0, len(timeStamp)), x_axis_label = 'Time (S)', y_axis_label = 'Intensity - Background')
#plot showing voltage
p.title.text = 'Click on legend entries to hide the corresponding lines'
p.extra_y_ranges = {"foo": Range1d(start=-0, end=1)}
p.add_layout(LinearAxis(y_range_name='foo', axis_label = 'Volt (V)'), 'right')
c = p.line(timevolt, volt, y_range_name = 'foo', line_color = (255,0, 0), line_alpha=0.5, line_width =2)

#plot showing mean data results
legend_it = [('Voltage', [c])]
for i, cgroup in enumerate(raw_data.keys()):
    c = p.line(x=timeStamp, y=np.mean(np.vstack(raw_data[cgroup]['intensity'].values), axis=0), line_width=2, line_color = colors[cgroup])
    legend_it.append((cgroup, [c]))
    
    
p.sizing_mode = 'scale_width'

legend = Legend(items = legend_it, location=(0, 200))
legend.click_policy="hide"
p.add_layout(legend, 'right')


    

#p.y_range.end = 400
#p.y_range.start =380
#output_file("Mean-RawIntensity.html", title = 'Stimulation Protocol')
#p.patch(timevolt2, volt2, y_range_name = 'foo')
show(p)
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-225-6125ce9ea76f> in <module>
     19 legend_it = [('Voltage', [c])]
     20 for i, cgroup in enumerate(raw_data.keys()):
---> 21     c = p.line(x=timeStamp, y=np.mean(np.vstack(raw_data[cgroup]['intensity'].values), axis=0), line_width=2, line_color = colors[cgroup])
     22     legend_it.append((cgroup, [c]))
     23 

KeyError: 'JRC_SS03795-LH728_Region2'
In [ ]:
def generateGroupNames(list1):
    #list1 = list that is converted to string
    for i, l in enumerate(list1):
        if not isinstance(l, str):
            list1[i] = str(l)
    groupname = list1[0]
    for cg in list1[1:]:
        groupname = groupname + ' ' + cg
    return groupname
In [ ]:
# getting the DeltaF/F responses for each time point then placing in a dictionary
deltaFF_data={}
parameters_to_compare = ['Genotype', 'Medium']
stimPeriods, stimoffPeriods = cc2.voltage(cc2.intensityDataFrame(exceldata).getVoltage()).getVoltageStopStarts()
prestim = 5 # time in s to include before stimulation
poststim = 20 # time after first stimulation to include
cgen= 'A74-1'
    

#add intensity data to dictionary
for cstimindex, cstim in enumerate(stimPeriods):
    prestart = cstim - prestim
    stop = stimoffPeriods[cstimindex] + poststim
    cstimS = [str(cstim)]
    for cgroup, frame in exceldata.groupby(parameters_to_compare):
        frame = frame[frame['roi'].str.contains('gamma')]
        dFF = cc2.intensityDataFrame(frame).getdFF(prestart, cstim, stop, exceldata, transgene[cgen]['response'])
        cgroup2 = cstimS.copy()
        cgroup2.extend(cgroup)
        groupname2 = generateGroupNames(cgroup2)
        deltaFF_data[groupname2] = dFF.deltaFF()
        deltaFF_data[groupname2 + 'timeStamp'] = dFF.timeStamp
        
In [ ]:
#default stim period
for cstimindex, cstim in enumerate(stimPeriods):
    #cstim = stimPeriods[1]
    prestart = cstim - prestim
    stop = stimoffPeriods[cstimindex] + poststim
    cstim = [str(cstim)]
    #get the min and max range for the data
    data = []
    for cgroup, frame in exceldata.groupby(parameters_to_compare):
        cgroup2 = cstim.copy()
        cgroup2.extend(cgroup)
        groupname2 = generateGroupNames(cgroup2)
        data.append( np.nanmean(deltaFF_data[groupname2], axis=0))
    data=np.vstack(data)
    data.shape
    min1 = np.min(data)*1.05
    max1 = np.max(data)*1.05
    p = figure(plot_width=800, plot_height=400, y_range=(min1, max1), x_range = (prestart, stop), x_axis_label = 'Time (S)', y_axis_label = 'deltaF/F')
    #plot showing voltage
    p.title.text = 'Click on legend entries to hide the corresponding lines'
    p.extra_y_ranges = {"foo": Range1d(start=-0, end=1)}
    p.add_layout(LinearAxis(y_range_name='foo', axis_label = 'Volt (V)'), 'right')
    c = p.line(timevolt, volt, y_range_name = 'foo', line_color = (255,0, 0), line_alpha=0.5, line_width =2)
    legend_it = [('Voltage', [c])]
    #add keys to dictionary that are the current drawings
    for cgroup, frame in exceldata.groupby(parameters_to_compare):
        cgroup = list(cgroup)
        cgroupD = cgroup.copy()
        cgroupD.extend(['Draw'])
        cgroupD = generateGroupNames(cgroupD)
        cgroup2 = cstim.copy()
        cgroup2.extend(cgroup)
        groupname2 = generateGroupNames(cgroup2)
        deltaFF_data[cgroupD] = deltaFF_data[groupname2]

    #plot showing mean data results
    source = ColumnDataSource(data=deltaFF_data)
    for cgroup, frame in exceldata.groupby(parameters_to_compare):
        cgroupcolor = generateGroupNames(cgroup)
        cgroupcolor = ' ' + cgroupcolor
        cgroup2 = cstim.copy()
        cgroup2.extend(cgroup)
        groupname2 = generateGroupNames(cgroup2)
        c = p.line(x=deltaFF_data[groupname2 + 'timeStamp'], y=np.nanmean(deltaFF_data[groupname2], axis=0), line_width=2, line_color = colors[cgroupcolor])
        legend_it.append((cgroupcolor, [c]))


    p.sizing_mode = 'scale_width'

    legend = Legend(items = legend_it, location=(0, 200))
    legend.click_policy="hide"
    p.add_layout(legend, 'right')




    #p.y_range.end = 400
    #p.y_range.start =380
    #output_file("Mean-RawIntensity.html", title = 'Stimulation Protocol')
    #p.patch(timevolt2, volt2, y_range_name = 'foo')
    show(p)
In [ ]:
 
In [ ]: